package com.cf.swagger.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;
import java.util.List;


@Configuration
@EnableSwagger2
public class SwaggerConfig {
    private ApiInfo apiInfo() {
        Contact contact = new Contact("yang", "", "");
        return new ApiInfo(
                "Yang的SwaggerAPI文档", // 标题
                "即使再小的帆也能远航",  // 描述
                "v1.0",   // 版本
                "https://blog.kuangstudy.com/",    // 组织链接
                contact,  // 联系人信息
                "Apache 2.0",    // 许可
                "http://www.apache.org/licenses/LICENSE-2.0",  // 许可连接
                new ArrayList()  // 扩展
        );
    }
    /**
     * 配置了swagger的Docket的bean实例
     */
    @Bean
    public Docket docket(){

        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("swagger2")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.cf.swagger.controller"))
                .paths(PathSelectors.any())
                .build()
                .apiInfo(apiInfo());
    }

}
